import { request } from './request';

export function getUsers(params) {
    return request({
        url: '/users',
        method: 'GET',
        params
    })
}

export function changeUserState(userId, state) {
    return request({
        url: `/users/${userId}/state/${state}`,
        method: 'PUT'
    })
}

export function handleAddUser(data) {
    return request({
        url: `/users`,
        method: 'POST',
        data
    })
}

export function getUserById(id) {
    return request({
        url: `/users/${id}`,
        method: 'GET'
    })
}

export function handleEditUser(id, data) {
    return request({
        url: `/users/${id}`,
        method: 'PUT',
        data
    })
}

export function deleteUserById(id) {
    return request({
        url: `/users/${id}`,
        method: 'DELETE'
    })
}

export function setUserRole(userId, data) {
    return request({
        url: `/users/${userId}/role`,
        method: 'PUT',
        data
    })
}